#!/usr/local/bin/python
# -*- coding: utf-8 -*-

from django.template import Context, Template

def sendmail(user, mail_tpl, data):
    t = Template(mail_tpl.body)
    c = Context(data)
    message = t.render(c)
    subject = mail_tpl.subject
    if not user.email: user.email = 'esimorre@c-s.fr'
    user.email_user(subject, message)
    print user.username
